/*
 * @lc app=leetcode.cn id=414 lang=rust
 *
 * [414] 第三大的数
 */

// @lc code=start
impl Solution {
    pub fn third_max(nums: Vec<i32>) -> i32 {
        let mut nums = nums;
        nums.sort();
        let mut ret = nums[nums.len() - 1];

        let mut j = 1;
        for i in (1..nums.len()).rev() {
            if nums[i - 1] != nums[i]
            {
                j += 1;
            }

            // print!("{}\n",j);

            if j == 3{
                ret = nums[i-1];
                break;
            }
        }


        return ret;
    }
}
// @lc code=end

